#ifndef HOMEPAGE_H
#define HOMEPAGE_H

#include <QWidget>
#include <QPropertyAnimation>
#include <QDebug>
#include <QtSerialPort/QSerialPort> // 提供访问串口的功能
#include <QtSerialPort/QSerialPortInfo> // 提供系统中存在的串口信息


namespace Ui {
class HomePage;
}

class HomePage : public QWidget
{
    Q_OBJECT

public:
    explicit HomePage(QWidget *parent = nullptr);
    ~HomePage();

private slots:


    void on_HomePage_StartButton_clicked();

    void on_HomePage_SetButton_clicked();

    void on_SettingPage_ReturnButton_clicked();

    void on_StartPage_NextButton_clicked();

    void on_StartPage_ReturnButton_clicked();

    void on_StartPage2_ReturnButton_clicked();


    void on_SelectTray1_Button_clicked();

    void on_SelectTray2_Button_clicked();

    void on_SelectTray3_Button_clicked();

    void on_DripNum_spinBox_valueChanged(int arg1);

    void on_SetDripNumType_1_Button_clicked();

    void on_SetDripNumType_2_Button_clicked();

    void on_SetDripNumType_3_Button_clicked();

    void on_stackedWidget_currentChanged(int arg1);

    void on_TrayTypePageButton_clicked();

    void on_DropNumSetPageButton_clicked();

    void on_DropTypePageButton_clicked();

    //一级菜单按键是否可按
    void if_DropNumSetPageButton_checkable();
    void if_DropTypePageButton_checkable();

    //二级菜单显示与隐藏函数
    void level_2_menu_show_hide();

    void on_Button_DropNum_Add_clicked();

    void on_Button_DropNum_Sub_clicked();

    void on_StartSetingPage_BoardType1Button_clicked();

    void on_ReturnToZeroButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_2_clicked();

    void on_pushButton_led_clicked();

    void on_heatButton_clicked();

    void on_pushButton_go_mainpage_clicked();

    void on_StartSetingPage_NextButton_clicked();

    void on_StartSetingPage_BoardType2Button_clicked();

    void on_StartSetingPage_BoardType3Button_clicked();

private:
    Ui::HomePage *ui;
    QSerialPort *serialPort;

    QPropertyAnimation *Level2Menu_show;
    bool Level2Menu_flag = false;
    bool sclectArea_clickable = false;

    int MaxNum_of_TrayType_1;
    int MaxNum_of_TrayType_2;
    int MaxNum_of_TrayType_3;
    int id1;

    int Tray_Type = 1;


    char send_data[12];

    bool HeatBoard_flag=0;
    unsigned char data_openheatborad[12]={0xb1,0x01,0x01,0xf1,0x01,0x00,0x00,0x00,0x00,0x00,0x0D,0x0A}; //设置热床为37度
    unsigned char data_offheatborad[12]={0xb1,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x0A}; //设置热床为关

    unsigned char data_return_Zero[12]={0xd0,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x0A}; //归零数据包

    int FanSpeed_Flag=0;
    unsigned char fan_speed[8]={0x00,0x00,0x01,0xf4,0x03,0x20,0x03,0xe8};
    unsigned char data_fan[12]={0xb1,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x0A}; //风扇

    bool UV_lamp_flag=0;
    unsigned char data_uvlamp[12]={0xb0,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x0A}; //uv灯

    bool LED_lamp_flag=0;
    unsigned char data_LEDlamp[12]={0xb0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x0A}; //led灯

    unsigned char data_work[12]={0xb5,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x0D,0x0A}; //工作数据包

    void SerialPortInit();
    void timerEvent(QTimerEvent *e);
    void updateButtonStyles(int selectedButton);

};

#endif // HOMEPAGE_H
